# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>

_name=resolvelib
pkgname=python-resolvelib
pkgver=0.8.1
pkgrel=1
pkgdesc="Resolve abstract dependencies into concrete ones"
url="https://github.com/sarugaku/resolvelib"
license=(custom:ISC)
arch=(any)
depends=(python)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-commentjson python-packaging python-pytest)
# test files not in pypi sdist tarballs: https://github.com/sarugaku/resolvelib/issues/108
# source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
source=($_name-$pkgver.tar.gz::https://github.com/sarugaku/resolvelib/archive/refs/tags/$pkgver.tar.gz)
sha512sums=('bc99d0661f3605d97074066df3c57edec8db40f66111f0d7a23ad88097ba4a162368ab396ef75632d09cd8a76417fbee2554d0cdb2f797795c246d16e7e3b955')
b2sums=('59bb02a08cf0f9bc6070cd5c5109826a7cacc5bda07479358fd591ff018bad761b53ed48f0a330e5ef60b8fa8d5db14ef044b662423e372aad7fc477df5b97ef')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -vDm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
